//
//  ALAssetsGroupEnumerator.h
//  OntheRoadV4
//
//  Created by ZhangYanhua on 15/1/6.
//  Copyright (c) 2015年 EricHuang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>
#import "ImageAsset.h"
#import "AssetsList.h"

@interface MyAssetsGroup : NSObject

@property (nonatomic, strong) id assetGroup;
@property (nonatomic, strong) NSString *groupIdentifier;
@property (nonatomic, strong) NSString *groupName;

@property (nonatomic, assign) NSInteger numberOfPhotos;
@property (nonatomic, assign) NSInteger numberOfVideos;

@property (nonatomic, strong) UIImage *groupThumbnail;

- (id)initWithAssetGroup:(ALAssetsGroup *)group;

- (id)initWithPHAssetCollection:(PHAssetCollection *)collection
              photosFetchResult:(PHFetchResult *)photosFetchResult
              videosFetchResult:(PHFetchResult *)videosFetchResult;

+ (MyAssetsGroup *)getMyGroupForIdentifier:(NSString *)identifier inArray:(NSArray *)groups;

@end

@interface ALAssetsGroupEnumerator : NSObject <AssetsListProtocol, PHPhotoLibraryChangeObserver>

+ (ALAssetsGroupEnumerator *)sharedInstance;


+ (BOOL)hasPermissionToAccessPhotoAndAlert:(BOOL)alert;

+ (BOOL)hasPermissionToAccessCameraAndAlert:(BOOL)alert;

@property (nonatomic, strong) NSMutableArray *curGroups;
@property (nonatomic, strong) NSMutableDictionary *cachedPhotos;

@property (nonatomic, assign) BOOL enumFailed;
@property (nonatomic, assign) BOOL isDuringEnum;

@property (nonatomic, strong) PHCachingImageManager *imageManager;

- (AssetsList *)getAssetsListOfGroup:(MyAssetsGroup *)group;
- (NSMutableArray *)getNotEmptyGroupsForPhoto:(BOOL)forPhoto;

@end
